]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
loginManager: listen to the correct object path
authorCosimo Cecchi <cosimoc@gnome.org>
Mon, 25 Mar 2013 17:25:30 +0000 (13:25 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Tue, 26 Mar 2013 00:53:13 +0000 (20:53 -0400)
Use GetSession() to get the valid object path for the current
XDG_SESSION_ID.

https://bugzilla.gnome.org/show_bug.cgi?id=696287

js/misc/loginManager.js
js/ui/screenShield.js

index 00e269b3b72161e021f059efbc9299eec0d50493..8543edea6299b80169b0f1b542687e4ba338be48 100644 (file)
@@ -33,6 +33,10 @@ const SystemdLoginManagerIface = <interface name='org.freedesktop.login1.Manager
     <arg type='s' direction='in'/>
     <arg type='h' direction='out'/>
 </method>
+<method name='GetSession'>
+    <arg type='s' direction='in'/>
+    <arg type='o' direction='out'/>
+</method>
 <method name='ListSessions'>
     <arg name='sessions' type='a(susso)' direction='out'/>
 </method>
@@ -136,15 +140,23 @@ const LoginManagerSystemd = new Lang.Class({
     // Having this function is a bit of a hack since the Systemd and ConsoleKit
     // session objects have different interfaces - but in both cases there are
     // Lock/Unlock signals, and that's all we count upon at the moment.
-    getCurrentSessionProxy: function() {
-        if (!this._currentSession) {
-            this._currentSession = new SystemdLoginSession(Gio.DBus.system,
-                                                           'org.freedesktop.login1',
-                                                           '/org/freedesktop/login1/session/' +
-                                                           GLib.getenv('XDG_SESSION_ID'));
+    getCurrentSessionProxy: function(callback) {
+        if (this._currentSession) {
+            callback (this._currentSession);
+            return;
         }
 
-        return this._currentSession;
+        this._proxy.GetSessionRemote(GLib.getenv('XDG_SESSION_ID'), Lang.bind(this,
+            function(result, error) {
+                if (error) {
+                    logError(error, 'Could not get a proxy for the current session');
+                } else {
+                    this._currentSession = new SystemdLoginSession(Gio.DBus.system,
+                                                                   'org.freedesktop.login1',
+                                                                   result[0]);
+                    callback(this._currentSession);
+                }
+            }));
     },
 
     canPowerOff: function(asyncCallback) {
@@ -233,15 +245,23 @@ const LoginManagerConsoleKit = new Lang.Class({
     // Having this function is a bit of a hack since the Systemd and ConsoleKit
     // session objects have different interfaces - but in both cases there are
     // Lock/Unlock signals, and that's all we count upon at the moment.
-    getCurrentSessionProxy: function() {
-        if (!this._currentSession) {
-            let [currentSessionId] = this._proxy.GetCurrentSessionSync();
-            this._currentSession = new ConsoleKitSession(Gio.DBus.system,
-                                                         'org.freedesktop.ConsoleKit',
-                                                         currentSessionId);
+    getCurrentSessionProxy: function(callback) {
+        if (this._currentSession) {
+            callback (this._currentSession);
+            return;
         }
 
-        return this._currentSession;
+        this._proxy.GetCurrentSessionRemote(Lang.bind(this,
+            function(result, error) {
+                if (error) {
+                    logError(error, 'Could not get a proxy for the current session');
+                } else {
+                    this._currentSession = new ConsoleKitSession(Gio.DBus.system,
+                                                                 'org.freedesktop.ConsoleKit',
+                                                                 result[0]);
+                    callback(this._currentSession);
+                }
+            }));
     },
 
     canPowerOff: function(asyncCallback) {
index 7d9654c16bf51825e7406962c24c9bb65aa9be09..c9c154343c82dc692ca98440a0f60544b381fdb5 100644 (file)
@@ -512,9 +512,12 @@ const ScreenShield = new Lang.Class({
                                    Lang.bind(this, this._prepareForSleep));
         this._inhibitSuspend();
 
-        this._loginSession = this._loginManager.getCurrentSessionProxy();
-        this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
-        this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); }));
+        this._loginManager.getCurrentSessionProxy(Lang.bind(this,
+            function(sessionProxy) {
+                this._loginSession = sessionProxy;
+                this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
+                this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); }));
+            }));
 
         this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });